package test_20220926;

////////////////////////////////////////////////////////////////


class OrderedApp
{
public static void main(String[] args)
{
		int maxSize = 100;             // array size
		OrdArray arr;                  // reference to array
		arr = new OrdArray(maxSize);   // create the array
		
		arr.insert(77);                // insert 10 items
		arr.insert(99);
		arr.insert(44);
		arr.insert(55);
		arr.insert(22);
		arr.insert(88);
		arr.insert(11);
		arr.insert(00);
		arr.insert(66);
		arr.insert(33);
		
		int searchKey = 505;            // search for item
		if( arr.find(searchKey) != arr.size() )
		System.out.println("Found " + searchKey);
		else
		System.out.println("Can't find " + searchKey);
		
		arr.display();                 // display items
		
		arr.delete(00);                // delete 3 items
		arr.delete(55);
		arr.delete(99);
		
		arr.display();                 // display items again
		
		OrdArray brr = new OrdArray(maxSize);
		
		brr.insert(55);
		brr.insert(0);
		brr.insert(99);
		
		brr.display();
		
		long[] res = OrdArray.merge(arr, brr);
		for(long x : res) {
		System.out.print(x + " ");
		}
		System.out.println();

//------------------------------------------------------------

		long[] sId = OrdArray.getRandArray(10);  //随机生成10个学生学号
		Greenhorn[] students = new Greenhorn[10];
		for(int i = 0; i < 10; i++) {
			students[i] = new Greenhorn(sId[i]);
			System.out.print(students[i].id + " ");
			OrdArray.addStudent(students, students[i], i + 1);
		}
		System.out.println();
		for(Greenhorn x : students) {
			System.out.print(x.id + " ");
		}
	}  // end main()
}  // end class OrderedApp
